package com.Jhu1.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.Jhu1.entity.Material;
import com.Jhu1.entity.PerOrder;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author 钟俊辉
 * @description 针对表【per_order】的数据库操作Mapper
 * @createDate 2025-01-16 20:18:25
 * @Entity com.yin.entity.PerOrder
 */
@Mapper
public interface PerOrderMapper extends BaseMapper<PerOrder> {
    @Select("""
            select * from per_order
            """)
    List<PerOrder> getAll();
    
    @Update("""
            update per_order
            set state = #{state}
            where id = #{id}
            """)
    void handle(Integer id, int state);
    
    
    @Insert("""
            insert into per_order(material_id,store_id,quantity,create_time,update_time)
            values(#{material.id},#{storeId},#{material.num},now(),now())
            """)
    void submit(Integer storeId, Material material);
    
    @Select("""
            select * from per_order
            where store_id=#{storeId}
            """)
    List<PerOrder> myOrder(Integer storeId);
    
    @Select("""
            select * from per_order
            where state=#{state}
            """)
    List<PerOrder> allByState(boolean state);
    
    @Select("""
            select * from per_order
            """)
    List<PerOrder> allByPage();
}




